#ifndef AVALON_READER_HPP
#define AVALON_READER_HPP
#include "Avalon/IO/IO.hpp"
#include "Avalon/Threading/Async.hpp"

namespace Avalon {
namespace IO {

  /*! \class Reader
   *  \brief Base class for reading data from a resource.
   *  \author Kamal Mansouri <kranar@hotmail.com>
   */
  class Reader {
    public:

      virtual ~Reader();

      //! Checks if this Reader is at the end of the data source.
      /*!
        \return <code>true</code> iff no more data can be read from this
                Reader.
      */
      virtual bool IsAtEndOfDataSource() = 0;

      //! Reads from the resource into a Buffer.
      /*!
        \param destination The Buffer to read to.
        \return The number of bytes read.
      */
      virtual Threading::Async<int>::Ptr Read(Buffer* destination);

      //! Reads from the resource into a specified destination.
      /*!
        \param destination The pointer to read to.
        \param size The maximum size to read.
        \return The number of bytes read.
      */
      virtual Threading::Async<int>::Ptr Read(void* destination, int size) = 0;

      //! Reads a from the resource into a Buffer up to a maximum size.
      /*!
        \param destination The Buffer to read to.
        \param size The maximum number of bytes to read.
        \return The number of bytes read.
      */
      virtual Threading::Async<int>::Ptr Read(Buffer* destination,
        int size) = 0;
  };
}
}

#endif // AVALON_READER_HPP
